﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace Primitive.Threading.Sync
{
    class MutexSomeClass : IDisposable
    {
        private readonly Mutex m_lock = new Mutex();
        public void Method1()
        {
            m_lock.WaitOne();
            Method2(); // Method2 递归地获取锁
            m_lock.ReleaseMutex();
        }
        public void Method2()
        {
            m_lock.WaitOne();
            m_lock.ReleaseMutex();
        }
        public void Dispose() { m_lock.Dispose(); }
    }
}
